package com.huaiyi.fms.open.authorization;

import cn.hutool.core.net.url.UrlBuilder;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.Method;

//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
public class Main {
    public static void main(String[] args) {
        String token = TokenUtil.getToken("127.0.0.1", 8896, "123456", "e2b93efde08395dc6e9ded7999b574c1");
        System.out.println("token:"+token);
        HttpRequestUtils requestUtils = new HttpRequestUtils(token, SignUtil.buildSign("e2b93efde08395dc6e9ded7999b574c1", token, "192.168.20.35", "/open/api/warning/info/mqtt/insert", System.currentTimeMillis() + ""));
        String json = "{\n" +
                "  \"appCode\": 91597016,\n" +
                "  \"cancellationDescription\": \"没电了，快点来电\",\n" +
                "  \"cateId\": 1,\n" +
                "  \"companyId\": 188,\n" +
                "  \"createTime\": \"2024-07-11 11:25:36\",\n" +
                "  \"equipmentCode\": \"N1236\",\n" +
                "  \"equipmentName\": \"电表1\",\n" +
                "  \"outerId\": \"123\",\n" +
                "  \"status\": 0,\n" +
                "  \"warningDetail\": \"测试，测试\",\n" +
                "  \"warningRuleId\": 0,\n" +
                "  \"warningType\": 1\n" +
                "}";
        HttpResponse httpResponse = requestUtils.getHttpRequest().setUrl(UrlBuilder.ofHttp("/open/api/warning/info/mqtt/insert").setPort(8896).setHost("192.168.20.35").setScheme("http").build())
                .body(json).setMethod(Method.POST).execute();
        System.out.println("数据:" + httpResponse.toString());
    }
}